<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
 /**
  * @todo 增加翻页功能
  */
 include("top.php");
?>
<table width="766" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="229" valign="top" bgcolor="#F0F0F0"><?php include("left.php");?></td>
    <td width="561" align="center" valign="top" bgcolor="#FFFFFF"><table width="550" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
      <?php
      @$bookname=$_POST['bookname'];
      @$keyword=$_POST['keyword'];
      @$vague=$_POST['vague'];
      @$price=intval($_POST['price']);
      @$class=$_POST['class'];
      @$tag=$_POST['tag'];
      if($tag=="1"){
          $tag=">";
      } else if($tag=="-1"){
          $tag="<";
      } else {
          $tag="=";
      }
      
      if($bookname!=""){//普通搜索
          $sql= exectue_sql_statement($conn, "select Book.book_id, book_name, book_introduction, unit_price, book_img, book_amount from Book, Store where Book.book_id=Store.book_id and Book.book_name like '%$bookname%'");
      } else if($vague=="1") {//高级搜索
          $sql= exectue_sql_statement($conn, "select Book.book_id, book_name, book_introduction, unit_price, book_img, book_amount from Book, Store where Book.book_id=Store.book_id and unit_price $tag $price and classify_id = $class and book_name like '$keyword'");
      } else {
          $sql= exectue_sql_statement($conn, "select Book.book_id, book_name, book_introduction, unit_price, book_img, book_amount from Book, Store where Book.book_id=Store.book_id and unit_price $tag $price and classify_id = $class and book_name = '$keyword'");
      }
      $info=sqlsrv_fetch_array($sql);
      if($info==false){
          echo "<script language='javascript'>alert('本站暂无类似图书!');history.go(-1);</script>";
      } else {
	?>
      <table width="530" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
        <tr bgcolor="#B0E0E6">
          <td width="92" height="25"><div align="center">图书名称</div></td>
          <td width="83"><div align="center">售价</div></td>
          <td width="62"><div align="center">数量</div></td>
          <td width="48"><div align="center">操作</div></td>
        </tr>
        <?php
		 do{
		?>
        <tr bgcolor="#FFFFFF">
          <td height="25"><div align="center"><?php echo $info['book_name'];?></div></td>
          <td height="25"><div align="center"><?php echo $info['unit_price'];?></div></td>
          <td height="25"><div align="center"><?php echo $info['book_amount'];?></div></td>
          <td height="25"><div align="center"><a href="bookinfo.php?book_id=<?php echo $info['book_id'];?>">查看</a></div></td>
        </tr>
        <?php
		   }while($info=sqlsrv_fetch_array($sql));
		 }
		?>
    </table></td>
  </tr>
</table>
<?php
 include("bottom.php");
?>